package com.game.exception;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.game.globalconst.Result;

import lombok.extern.slf4j.Slf4j;

/**
 * 
 * @author ZGame 处理全局异常
 *
 */
@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
	@ExceptionHandler(value = AuthFailException.class)
	@ResponseBody
	public Result authFailException(HttpServletRequest req, AuthFailException e) {
		log.error(" 权限验证失败 uid:" + e.getUserId());
		Result r = Result.build();
		r.put("Result", false);
		r.put("Notice", e.getNotice());
		return r;
	}
}
